-- msg_revenge_result
-- Create by panyl
-- 遗迹复仇结果

return function(lpc)
    local para = lpc.result;

    -- 掠夺战斗结果
    trace("msg_revenge_result: ", tableToString(para));

    local target = lpc.target;
    local record = ME.user.dbase:query("relic_combat_record", {})[target];

    local result        = para.result;
    local attackerInfo  = para.attacker;
    local defenserInfo  = para.defenser;
    local bonus;
    local curTime = TimeM.getServerTime();

    -- 胜利了
    if result == 1 then
        bonus = FormulaM.invoke("CALC_RELIC_ROB_BONUS", (record.real_rob or record.scrap) + record.ex_resource, record.money or 0);

        -- 复仇时间
        record["revenge_time"] = curTime;
    end

    if para.fail_times then
        record["fail_times"] = para.fail_times;
    end

    -- 记录复仇时间
    if para.last_revenge_time then
        record["lastRevengeTime"] = para.last_revenge_time;
    end

    -- 抛出更新事件
    EventMgr.fire(event.REVENGE_LIST_UPDATE, {});

    -- 创建一个战场
    SkyCombatM.createBattle(attackerInfo, defenserInfo, result, para.record, bonus);
end
